﻿SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON

GO


CREATE PROCEDURE [dbo].[bhp_temp_AddBlogSettingsStructure]
AS
BEGIN

	DECLARE
		@BlogSettingsTabId	INT,
		@Sort							INT


	SET @Sort = 0

	EXECUTE [dbo].[n_TableAdd] 'BLOG_SETTINGS', 900900
	
	SELECT @BlogSettingsTabId = id FROM n_Tree t WHERE t.name = 'BLOG_SETTINGS'
	
	-- BLOG_SETTINGS.title
	SET @Sort = @Sort + 1
	EXEC [dbo].[n_ColFAdd] @rel = @BlogSettingsTabId, @name = N'title', @typ = 2, @siz1 = 1000, @siz2 = 1, @user = 900900
	ALTER TABLE BLOG_SETTINGS ALTER COLUMN title nvarchar(1000) NOT NULL
	INSERT INTO bht_Columns (ColumnId, DisplayName, [Description], Sort)
	SELECT
		id, N'Tytuł', N'', @Sort
	FROM
		n_Tree t
	WHERE
		parent = @BlogSettingsTabId
		AND name = N'title'

	-- BLOG_SETTINGS.subtitle
	SET @Sort = @Sort + 1
	EXEC [dbo].[n_ColFAdd] @rel = @BlogSettingsTabId, @name = N'subtitle', @typ = 2, @siz1 = 1000, @siz2 = 1, @user = 900900
	INSERT INTO bht_Columns (ColumnId, DisplayName, [Description], Sort)
	SELECT
		id, N'Tekst pod tytułem', N'', @Sort
	FROM
		n_Tree t
	WHERE
		parent = @BlogSettingsTabId
		AND name = N'subtitle'

	-- BLOG_SETTINGS.moduleId
	SET @Sort = @Sort + 1
	EXEC [dbo].[n_ColFAdd] @rel = @BlogSettingsTabId, @name = N'moduleId', @typ = 1, @siz1 = 1000, @siz2 = 1, @user = 900900
	INSERT INTO bht_Columns (ColumnId, DisplayName, HideForEdition)
	SELECT
		id, N'Place ID', 1
	FROM
		n_Tree t
	WHERE
		parent = @BlogSettingsTabId
		AND name = N'moduleId'
		
END
GO

EXEC [bhp_temp_AddBlogSettingsStructure]
GO

DROP PROCEDURE [bhp_temp_AddBlogSettingsStructure]